<template>
  <div id="app">
    <h2>测试题</h2>
    <SubjectItem @submit="submitFn"></SubjectItem>
    <FlagItem :statusArr='statusArr'></FlagItem>
  </div>
</template>

<script>
import SubjectItem from "./components/SubjectItem.vue";
import FlagItem from "./components/FlagItem.vue";
export default {
  
  data() {
    return {
      statusArr: []
    };
  },
  components: {
    SubjectItem,
    FlagItem,
  },
  methods:{
    submitFn (val1,val2) {
      if(val1 === val2){
        this.statusArr.push({
          cont: '回答正确',
          classAttribute: 'right'
        })
      }else if(val1 !== val2){
        if(val1 === undefined){
          this.statusArr.push({
            cont: '未完成',
            classAttribute: 'undo'
          })
        }else{
          this.statusArr.push({
            cont: '回答错误',
            classAttribute: 'error'
          })
      }
      }
    }
  }
}
</script>

<style>
body {
  background-color: #eee;
}

#app {
  background-color: #fff;
  width: 500px;
  margin: 50px auto;
  box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.5);
  padding: 2em;
}
</style>